<!DOCTYPE html>
<html>
<head>
    <title>基础数据登记</title>
<#include "../common/common.ftl"/>
    <link rel="stylesheet" href="/style/contractForm.css" media="all">
</head>
<body>
<div class="layui-fluid">
    <form class="layui-form layui-bg-white" id="fileInfoForm">
        <input type="hidden" name="fileInfoId" value="${fileInfo.id}">
        <table class="layui-table">
            <tr>
                <td class="x-center layui-bg-gray" width="15%">上传人员</td>
                <td>${(fileInfo.uploadPerson)!}</td>
                <td class="x-center layui-bg-gray" width="15%">上传日期</td>
                <td>${fileInfo.uploadDate?string("yyyy-MM-dd HH:mm")}</td>
            </tr>
            <tr>
                <td class="x-center layui-bg-gray" width="15%">文件大小</td>
                <td colspan="3">${fileInfo.fileSize / 1024 / 1024}MB</td>
            </tr>
            <tr>
                <td class="x-center layui-bg-gray">文件名称</td>
                <td><input type="text" class="layui-input" name="fileName" value="${fileInfo.fileName}"></td>
                <td class="x-center layui-bg-gray">排序号</td>
                <td><input type="text" class="layui-input" name="sortNum" value="${fileInfo.sortNum}" lay-verify="digits"></td>
            </tr>
        </table>
        <button type="button" style="display: none;" class="layui-btn" id="submitBtn" name="submitBtn" lay-submit=""
                lay-filter="submit">
            立即提交
        </button>
    </form>
</div>
<script src="/layui/layui.js" charset="utf-8"></script>
<script>
    layui.config({
        base: '/layui/lay/modules/' //静态资源所在路径
    }).use(['form', 'jquery', 'layer'], function () {
        var form = layui.form,layer = layui.layer,$ = layui.jquery;

        //自定义验证规则
        form.verify({
            digits: function (value) {
                //正整数
                var r = /^\+?[1-9][0-9]*$/;
                if (value != undefined && value != "") {
                    if (!r.test(value)) {
                        return '请输入大于0的整数！';
                    }
                }
            }
        });

        //父页面通过submit按钮click方法，触发以下验证功能
        form.on('submit(submit)', function (data) {
            $.ajax({
                url: "fileInfoSave"
                , type: "post"
                , data: $("#fileInfoForm").serialize()
                , success: function (data) {
                    if (data.code == "0000") {
                        layer.msg(data.message, {time: 500}, function () {
                            parent.showRight("${fileInfo.fileCategory}");
                            var parentIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(parentIndex);
                        });
                    } else {
                        layer.msg(data.message, {anim: 6, icon: 2});
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
